package com.example.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.entity.AccountBook;
import com.example.demo.mapper.AccountBookMapper;
import com.example.demo.service.IAccountBookService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AccountBookServiceImpl extends ServiceImpl<AccountBookMapper, AccountBook> implements IAccountBookService {
    @Override
    public AccountBook selectByAccountPassword(String account, String password) {
        LambdaQueryWrapper<AccountBook> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(AccountBook::getAccount, account).eq(AccountBook::getPassword, password);
        List<AccountBook> list = list(queryWrapper);
        if (list == null || list.isEmpty()) return null;
        return list.get(0);
    }
}
